/**
 * 
 */
package com.yst.metho.web.application.user.actions;

import nextapp.echo2.app.Extent;
import nextapp.echo2.app.event.ActionEvent;

import com.yst.metho.web.application.SuiviProdApp;
import com.yst.metho.web.application.components.GenericEditWindow;
import com.yst.metho.web.application.components.listingview.ToolbarAction;
import com.yst.metho.web.application.user.UserListModel;
import com.yst.metho.web.application.user.UserPane;
import com.yst.suivi.data.rights.Right;

/**
 * @author perso
 * 
 */
public class CreateUser extends ToolbarAction
{
	public static final Extent USER_VIEW_HEIGHT = new Extent(340, Extent.PX);

	private UserListModel mModel;

	/**
	 * 
	 */
	private static final String CREATE_USER_COMMAND = "CreateUser";

	public CreateUser(UserListModel model)
	{
		super(Right.CREATE_USER, "Create");
		mModel = model;
		setActionCommand(CREATE_USER_COMMAND);
		addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		if (CREATE_USER_COMMAND.equals(e.getActionCommand()))
		{
			UserPane view = new UserPane();
			GenericEditWindow window = new GenericEditWindow(view, "Creation d'un utilisateur", new ModifyUserBtn(mModel, view));
			window.setHeight(USER_VIEW_HEIGHT);
			SuiviProdApp.getApp().getDefaultWindow().getContent().add(window);
		}
	}
}
